home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / checko1a / conflict.frm (.txt) < prev    next >
Visual Basic Form  |  1999-09-16  |  13KB  |  313 lines

  1. VERSION 5.00
  2. Begin VB.Form frmConflicts 
  3.    Caption         =   "Resolve Conflicts"
  4.    ClientHeight    =   1995
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1995
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Frame fraProgram 
  13.       Caption         =   "Compare with:"
  14.       Height          =   855
  15.       Left            =   3240
  16.       TabIndex        =   4
  17.       Top             =   120
  18.       Width           =   1335
  19.       Begin VB.OptionButton optProgram 
  20.          Caption         =   "WinDiff"
  21.          Height          =   255
  22.          Index           =   1
  23.          Left            =   120
  24.          TabIndex        =   6
  25.          Top             =   480
  26.          Value           =   -1  'True
  27.          Width           =   1095
  28.       End
  29.       Begin VB.OptionButton optProgram 
  30.          Caption         =   "FC (DOS)"
  31.          Height          =   255
  32.          Index           =   0
  33.          Left            =   120
  34.          TabIndex        =   5
  35.          Top             =   240
  36.          Width           =   1095
  37.       End
  38.    End
  39.    Begin VB.CommandButton cmdDelete 
  40.       Caption         =   "Delete"
  41.       Enabled         =   0   'False
  42.       Height          =   495
  43.       Left            =   120
  44.       TabIndex        =   3
  45.       Top             =   1380
  46.       Width           =   1215
  47.    End
  48.    Begin VB.CommandButton cmdCompare 
  49.       Caption         =   "Compare"
  50.       Enabled         =   0   'False
  51.       Height          =   495
  52.       Left            =   3060
  53.       TabIndex        =   2
  54.       Top             =   1380
  55.       Width           =   1515
  56.    End
  57.    Begin VB.CommandButton cmdEdit 
  58.       Caption         =   "Edit"
  59.       Enabled         =   0   'False
  60.       Height          =   495
  61.       Left            =   1440
  62.       TabIndex        =   1
  63.       Top             =   1380
  64.       Width           =   1515
  65.    End
  66.    Begin VB.ListBox lstConflicts 
  67.       Height          =   1230
  68.       Left            =   120
  69.       Sorted          =   -1  'True
  70.       TabIndex        =   0
  71.       Top             =   48
  72.       Width           =   3015
  73.    End
  74. Attribute VB_Name = "frmConflicts"
  75. Attribute VB_GlobalNameSpace = False
  76. Attribute VB_Creatable = False
  77. Attribute VB_PredeclaredId = True
  78. Attribute VB_Exposed = False
  79. Option Explicit
  80. 'find Windows version API functions
  81. Private Const VER_PLATFORM_WIN32s = 0
  82. Private Const VER_PLATFORM_WIN32_WINDOWS = 1
  83. Private Const VER_PLATFORM_WIN32_NT = 2
  84. Private Type OSVERSIONINFO
  85.   OSVSize         As Long         'size, in bytes, of this data structure
  86.   dwVerMajor      As Long         'ie NT 3.51, dwVerMajor = 3; NT 4.0, dwVerMajor = 4.
  87.   dwVerMinor      As Long         'ie NT 3.51, dwVerMinor = 51; NT 4.0, dwVerMinor= 0.
  88.   dwBuildNumber   As Long         'NT: build number of the OS
  89.                                   'Win9x: build number of the OS in low-order word.
  90.                                   '       High-order word contains major & minor ver nos.
  91.   PlatformID      As Long         'Identifies the operating system platform.
  92.   szCSDVersion    As String * 128 'NT: string, such as "Service Pack 3"
  93.                                   'Win9x: 'arbitrary additional information'
  94. End Type
  95. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  96. 'Private Const INVALID_HANDLE_VALUE = -1
  97. Private Const MAX_PATH = 260
  98. 'Private Type FILETIME
  99. '    dwLowDateTime As Long
  100. '    dwHighDateTime As Long
  101. 'End Type
  102. 'Private Type WIN32_FIND_DATA
  103. '    dwFileAttributes As Long
  104. '    ftCreationTime As FILETIME
  105. '    ftLastAccessTime As FILETIME
  106. '    ftLastWriteTime As FILETIME
  107. '    nFileSizeHigh As Long
  108. '    nFileSizeLow As Long
  109. '    dwReserved0 As Long
  110. '    dwReserved1 As Long
  111. '    cFileName As String * MAX_PATH
  112. '    cAlternate As String * 14
  113. 'End Type
  114. 'find file API functions
  115. Private Declare Function SearchTreeForFile Lib "imagehlp.dll" (ByVal sRootPath As String, ByVal InputPathName As String, ByVal OutputPathBuffer As String) As Boolean
  116. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
  117. 'enumerate drives API functions
  118. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  119. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  120. Private Const DRIVE_REMOVABLE = 2
  121. Private Const DRIVE_FIXED = 3
  122. Private Const DRIVE_REMOTE = 4
  123. Private Const DRIVE_CDROM = 5
  124. Private Const DRIVE_RAMDISK = 6
  125. Private Function GetWinDir() As String
  126.     Dim nSize As Long
  127.     Dim tmp As String
  128.     tmp = Space$(256)
  129.     nSize = Len(tmp)
  130.     Call GetWindowsDirectory(tmp, nSize)
  131.     GetWinDir = Trim(tmp)
  132. End Function
  133. Private Function IsWin95() As Boolean
  134.     Dim OSV As OSVERSIONINFO
  135.     OSV.OSVSize = Len(OSV)
  136.     If GetVersionEx(OSV) = 1 Then 'PlatformId contains a value representing the OS.
  137.          IsWin95 = (OSV.PlatformID = VER_PLATFORM_WIN32_WINDOWS) And _
  138.                    (OSV.dwVerMajor = 4 And OSV.dwVerMinor = 0)
  139.     End If
  140. End Function
  141. Private Function IsWin98() As Boolean
  142.     Dim OSV As OSVERSIONINFO
  143.     OSV.OSVSize = Len(OSV)
  144.     If GetVersionEx(OSV) = 1 Then 'PlatformId contains a value representing the OS.
  145.          IsWin98 = (OSV.PlatformID = VER_PLATFORM_WIN32_WINDOWS) And _
  146.                    (OSV.dwVerMajor > 4) Or _
  147.                    (OSV.dwVerMajor = 4 And OSV.dwVerMinor > 0)
  148.     End If
  149. End Function
  150. Private Function IsWinNT() As Boolean
  151.     Dim OSV As OSVERSIONINFO
  152.     OSV.OSVSize = Len(OSV)
  153.     If GetVersionEx(OSV) = 1 Then 'PlatformId contains a value representing the OS.
  154.          IsWinNT = (OSV.PlatformID = VER_PLATFORM_WIN32_NT)
  155.     End If
  156. End Function
  157. Private Function GetFileLocation(sDrive2Scan As String, sFile2Find As String) As String
  158.     Dim sResult As String
  159.     sResult = Space(MAX_PATH)
  160.     If SearchTreeForFile(sDrive2Scan, sFile2Find, sResult) Then
  161.         GetFileLocation = Left(sResult, InStr(sResult, vbNullChar) - 1)
  162.     End If
  163. End Function
  164. Private Function FindOtherHardDrive() As String
  165.     Dim i%, allDrives$, curDrive$, drvType$
  166.     'get the list of all available drives
  167.     allDrives$ = Space$(64)
  168.     Call GetLogicalDriveStrings(Len(allDrives$), allDrives$)
  169.     allDrives$ = Trim$(allDrives$)
  170.     i% = 1
  171.     While InStr(i%, allDrives$, Chr$(0)) > 0 'get the drive type
  172.         curDrive$ = Mid$(allDrives$, i%, InStr(i%, allDrives$, Chr$(0)) - i%)
  173.         drvType$ = rgbDrvType(curDrive$)
  174.         i% = InStr(i%, allDrives$, Chr$(0)) + 1
  175.         If drvType$ = "Hard drive" Then
  176.             If LCase$(curDrive$) <> LCase$(Left$(GetWinDir, InStr(3, GetWinDir, "\"))) Then
  177.                 FindOtherHardDrive = curDrive$
  178.                 Exit Function
  179.             End If
  180.         End If
  181.     Wend
  182. End Function
  183. Private Function rgbDrvType(RootPathName) As String
  184.     'Passed is the drive to check. Returned is the type of drive.
  185.      Dim r As Long
  186.      r = GetDriveType(RootPathName)
  187.      Select Case r
  188.         Case 0: rgbDrvType = "Cannot be determined"
  189.         Case 1: rgbDrvType = "Does not exist"
  190.         Case DRIVE_REMOVABLE:
  191.             Select Case LCase$(Left$(RootPathName, 1))
  192.                 Case "a", "b": rgbDrvType = "Floppy drive"
  193.                 Case Else: rgbDrvType = "Removable drive"
  194.             End Select
  195.         Case DRIVE_FIXED:   rgbDrvType = "Hard drive"
  196.         Case DRIVE_REMOTE:  rgbDrvType = "Network drive"
  197.         Case DRIVE_CDROM:   rgbDrvType = "CD-ROM drive"
  198.         Case DRIVE_RAMDISK: rgbDrvType = "RAM disk"
  199.     End Select
  200. End Function
  201. Private Sub cmdCompare_Click()
  202.     If optProgram(0).Value = True Then
  203.         If IsWinNT Then
  204.             On Error Resume Next
  205.             Shell "cmd /k fc /c " & Chr$(34) & frmCheckInOut.txtLocalDir & lstConflicts & Chr$(34) & " " & Chr$(34) & frmCheckInOut.txtNetDir & lstConflicts & Chr$(34) & " | more", vbNormalFocus
  206.             If Err <> 0 Then
  207.                 MsgBox "Error: could not run 'cmd /k fc'."
  208.             End If
  209.             On Error GoTo 0
  210.         Else
  211.             Dim f%
  212.